import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'blur_mask.dart';

class HUD extends StatelessWidget {
  const HUD(this.text, {Key? key}) : super(key: key);

  final String? text;

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            const SizedBox(
              width: 30,
              height: 30,
              child: CircularProgressIndicator(
                strokeWidth: 3,
              ),
            ),
            if (text != null) ...[
              const SizedBox(height: 15),
              Text(
                text ?? "",
                style: const TextStyle(
                    color: Colors.white,
                    fontSize: 14,
                    fontWeight: FontWeight.w100),
              ),
            ],
          ],
        ),
      ),
    );
  }

  static show({String? msg}) {
    BlurMask.show(HUD(msg), barrierDismissible: false);
  }

  static hide() {
    Get.back();
  }
}
